﻿using Masuit.Tools.Systems;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Canteen.Core.Models
{
    //商品
    public class Product : BaseEntity
    {
        public Product()
        {
            Code = SnowFlake.GetInstance().GetUniqueId();
        }

        [StringLength(12), Required]
        [Column(TypeName = "VARCHAR(12)")]
        public string Code { get; set; }//唯一标识

        //所属那个商家
        [ForeignKey("StoreId")]
        public int StoreId { get; set; }//Store外键
        public virtual Store Store { get; set; }//Store导航属性

        [MaxLength(64)]
        public string Name { get; set; }//商品名称
        public int? Type { get; set; }//商品类型
        [MaxLength(256)]
        public string ProductImgUrl { get; set; }//商品图片

        [Column(TypeName = "MONEY")]
        public decimal? Price { get; set; }//单价
        public int Number { get; set; }//数量

        [Column(TypeName = "DECIMAL(5,2)")]
        public decimal? VitaminA { get; set; }//维生素A
        [Column(TypeName = "DECIMAL(5,2)")]
        public decimal? VitaminB { get; set; }//维生素B
        [Column(TypeName = "DECIMAL(5,2)")]
        public decimal? VitaminC { get; set; }//维生素C

        public List<ShopOrderProducts> ShopOrderProductList { get; set; } = new List<ShopOrderProducts>();
        
    }
}
